<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-09-25
 * Time: 16:21
 */

namespace App\Models;

/**
 * Class OrderItems
 * @package App\Models
 */
class OrderItems extends BaseModel
{
    /**
     * 与模型关联的数据表
     *
     * @var string
     */
    protected $table = 'order_items';

    /**
     * 主键
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 需要被转换成日期的属性。
     *
     * @var array
     */
    protected $dates = ['reviewed_at'];

    /**
     * @var array
     */
    protected $guarded = ['id'];

    /**
     * @var bool
     */
    public $timestamps = false;

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function goods(){
        return $this->belongsTo(Goods::class, 'goodsId', 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function goodsSku(){
        return $this->belongsTo(GoodsSku::class, 'goodsSkuId', 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function order(){
        return $this->belongsTo(Order::class, 'orderId', 'id');
    }
}
